package top.fzqblog.firstapp;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import butterknife.BindView;
import butterknife.ButterKnife;
import top.fzqblog.adapter.GlideAdapter;
import top.fzqblog.service.RequestApi;
import top.fzqblog.model.Meizi;

/**
 * Created by 抽离 on 2017/9/25 0025.
 */

public class RetrofitGlideTest extends AppCompatActivity implements RequestApi.RequestCallback<Meizi>{


    @BindView(R.id.recycleviewlayout)
    public RecyclerView recyclerView;

    private GlideAdapter adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.recycleviewtest);
        ButterKnife.bind(this);
        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
        RequestApi requestApi = new RequestApi();
        requestApi.getMeizi(this, 1);
    }


    @Override
    public void onFinsh(Meizi data) {
        Log.i("tag", data.toString());
        adapter = new GlideAdapter(this, data);
        recyclerView.setAdapter(adapter);
    }

    @Override
    public void onError(Throwable throwable) {
        Log.i("tag", throwable.toString());
    }
}
